package org.smile.db.jdbc;

import org.smile.db.criteria.*;

import java.util.Map;

/**
 *    使用jdbc实现的一个Criteria操作
 * @author 胡真山
 *
 */
public class JdbcRecordCriteriaImpl extends AbstractNoLambdaCriteria<JdbcMapRecord> {


	public JdbcRecordCriteriaImpl(JdbcMapRecordDao recordDao) {
		this.noLambdaRecordDao =recordDao;
		this.keyColumnSwapper=recordDao.cfg().keyColumnSwaper;
	}

	@Override
	protected CriterionVisitor getBuildUpdateInfoVisitor(StringBuilder whereSql, Map<String, Object> params) {
		return new NameJdbcWhereCriterionVisitor(whereSql,params);
	}


	protected  class NameJdbcWhereCriterionVisitor extends NamedWhereCriteriaVisitor {

		NameJdbcWhereCriterionVisitor(StringBuilder whereSql, Map<String,Object> params){
			super(whereSql,params);
		}

		@Override
		protected String toColumnName(String fieldName){
			return  keyColumnSwapper.keyToColumn(fieldName);
		}
	}

}
